<{include file="Public/top.html"}>
<style>
    .album img{width: 80px;}
    td{border:1px solid #e7e7eb}
    td.e{background-color:#ffE7FE;}
    td.status_0{color:red}
    td.status_1{color:green}
    td.status_2{color:blue}
    td.status_3{color:brown}
    #startDate,#endDate{width: 100px !important;text-align: center}
</style>
</head>
<body>
<div id="warpper">
    <div class="content">
        <div class="location">价格管理</div>

        <{include file= "Status/nav.html"}>

        <div class="filedSet" style="padding-bottom: 0;">
            <div class="search">
                    <div class="ui-form-item inline-block">
                        <button type="button" disabled id="prev" class="ui-button" >上一周</button>
                    </div>
                    <div class="ui-form-item inline-block">
                        <button type="button"  id="next" class="ui-button" >下一周</button>
                    </div>
            </div>
        </div>
        <!--表格内容-->
        <div class="mainGrid">
        </div>


    </div>
</div>



<div class="form-box border0 " id="setPrice" style="display:none">
    <form  class="ui-form" method="post" id="addManagerForm">
        <input type="hidden"  name="rid" id="rid" />

        <div class="ui-form-item">
            <label class="ui-label">房间名称：</label>
            <input type="text" class="ui-text" id="roomName" readonly/>
        </div>
        <div class="ui-form-item">
            <label class="ui-label">日期范围：</label>
            <input id="startDate" name="startDate"  readonly class="ui-text" type="text" required/>
            至
            <input id="endDate" name="endDate"   class="ui-text" type="text" required/>
        </div>
        <div class="ui-form-item">
            <label class="ui-label">房间状态：</label>
            <select class="ui-select" name="status">
                <{html_options options=$roomStatus }>
            </select>
        </div>

        <div class="integral_btn-group">
            <input type="submit" value="提交" class="ui-button"/>
        </div>

    </form>
</div>

<script>
    datePickter('startDate','endDate',true);
    queryPrice();
    var time=0;
    function queryPrice(direct){
        if(direct==1){
            time +=86400*7;
        }else if(direct==-1){
            time -=86400*7;
        }else{
            time=0;
        }
        $.post('<{u(statusList)}>',{time:time},function(ret){
            $('.mainGrid').html(ret.HTML).find('td').on('click',function(e){
                var roomName=$(e.target).parent().find('th').text();
                $('#roomName').val(roomName);
                var rid=e.target.dataset['rid'];
                var date=e.target.dataset['date'];
                $('#startDate,#endDate').val(date);
                $('#rid').val(rid);
                layer.open({
                    area:['400px','300px'],
                    type: 1,
                    title:'价格特别设定',
                    content: $('#setPrice') //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
                });

            });
            time=ret.time;
            if(time<=<{time()}>){
                $('#prev').attr('disabled','disabled').css({'background-color':'gray'});
            }else{
                $('#prev').removeAttr('disabled').css({'background-color':'#2077d1'});
            }
        },'JSON');
    }

    $('#next').click(function(){
        queryPrice(1);
    });
    $('#prev').click(function(){
        queryPrice(-1);
    });


    $('form').on('submit',function(){
        var data=$('form').serialize();
        if(parseInt($('#price').val())<=0){
            layer.msg("房价必须大于0元");
            return false;
        }

        $.post('<{u(setSpecial)}>',data,function(ret){
            if(ret.status!=0){
                layer.msg(ret.msg);
            }else{
                layer.alert('设置成功',function(){location.reload()})
            }
        },'json');


        return false;
    });
</script>
</body>
<{include file="Public/foot.html" }>